# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=wpewebkit
pkgver=2.36.3
pkgrel=0
pkgdesc="WebKit port optimized for embedded devices"
url="https://wpewebkit.org"
# riscv64: fails to link
arch="all !riscv64"
license="other"
makedepends="
	at-spi2-core-dev
	bubblewrap
	cairo-dev
	cmake
	gperf
	gst-plugins-base-dev
	gtk-doc
	harfbuzz-dev
	lcms2-dev
	libepoxy-dev
	libgcrypt-dev
	libseccomp-dev
	libsoup3-dev
	libtasn1-dev
	libwpe-dev
	libwpebackend-fdo-dev
	libxkbcommon-dev
	libxslt-dev
	ninja
	openjpeg-dev
	perl
	ruby-dev
	wayland-dev
	wayland-protocols
	woff2-dev
	xdg-dbus-proxy
	"
subpackages="$pkgname-dev $pkgname-doc"
source="https://wpewebkit.org/releases/wpewebkit-$pkgver.tar.xz
	patch-gettext.patch
	"

build() {
	case "$CARCH" in
	x86|armhf)
		# work around OOM on x86/armhf
		CXXFLAGS="$CXXFLAGS -U_FORTIFY_SOURCE"
	esac
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DPORT=WPE \
		-DENABLE_MINIBROWSER=On \
		-DENABLE_GTKDOC=On \
		-DENABLE_JOURNALD_LOG=Off \
		-GNinja \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
33a70e91fdbd40d017d9a246d0e86d94513c7c45533b8fbe7ce81d1d3b8991d9cc6d362133b21c21b5e90d334d496d1a79ac3b732c4a2d4fae8cdded8d5957c7  wpewebkit-2.36.3.tar.xz
4316330f0c42fcfe800210bdbeabbb6bdcf532b71e2761550b8a753499d801fd0405cc961a516dfddfc28c3a6cf0c17b6db461ff51158238b8d874bf75b799f2  patch-gettext.patch
"
